forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 147
Handle "Escape" key for TextInput #1044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Saadnajmi
commented
Feb 23, 2022
HeyImChris
approved these changes
Feb 24, 2022
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Feb 24, 2022
* wip * onKeyPress works * Minor cleanup * spaces not tabs
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Feb 24, 2022
* wip * onKeyPress works * Minor cleanup * spaces not tabs
This was referenced Feb 24, 2022
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Feb 24, 2022
* wip * onKeyPress works * Minor cleanup * spaces not tabs
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Feb 24, 2022
* wip * onKeyPress works * Minor cleanup * spaces not tabs
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Feb 24, 2022
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Feb 24, 2022
christophpurrer
pushed a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Aug 8, 2022
This extends the ability to intercept `keyDown` and `keyUp` events to `TextInput`. We need this for the ability to insert newlines when holding shift in chat, along with support arrow up/down from the search input. Will the change here cause a conflict with microsoft#1044 ?
christophpurrer
pushed a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Aug 10, 2022
This extends the ability to intercept `keyDown` and `keyUp` events to `TextInput`. We need this for the ability to insert newlines when holding shift in chat, along with support arrow up/down from the search input. Will the change here cause a conflict with microsoft#1044 ?
4 tasks
christophpurrer
pushed a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Aug 10, 2022
This extends the ability to intercept `keyDown` and `keyUp` events to `TextInput`. We need this for the ability to insert newlines when holding shift in chat, along with support arrow up/down from the search input. Will the change here cause a conflict with microsoft#1044 ?
christophpurrer
pushed a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Aug 11, 2022
This extends the ability to intercept `keyDown` and `keyUp` events to `TextInput`. We need this for the ability to insert newlines when holding shift in chat, along with support arrow up/down from the search input. Will the change here cause a conflict with microsoft#1044 ?
christophpurrer
pushed a commit
to christophpurrer/react-native-macos
that referenced
this pull request
Aug 28, 2022
This extends the ability to intercept `keyDown` and `keyUp` events to `TextInput`. We need this for the ability to insert newlines when holding shift in chat, along with support arrow up/down from the search input. Will the change here cause a conflict with microsoft#1044 ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please select one of the following
Summary
TextInput did not properly handle the "Escape" Key. This is probably because iOS doesn't have an escape key, so we have to special case it for macOS. Normally,
onKeyPress
is called for each key that changes the text inside a TextInput. There are a few exceptions: Enter, Delete, Backspace. Those keys have special keybindings in Appkit, and are handled in a different codepath as described here -> onmyway133/blog#635 .My change adds "Escape" as one of these special cased keys. Pressing Escape will end editing, remove focus from the text field, and send a KeyPress event. This seemed like the most reasonable defualt.
Changelog
[macOS] [Fixed] - Handle Escape key for TextInput
Test Plan
I put some console.logs() inside the RNTesterPage for TextInput to verify Escape was being hit inside
onKeyPress
.